$(function(){
	
	$('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
	
	$(window).resize(function(){  
		$('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
    });
	
 	$('#logining').click(function() {
 		$('#account').validatebox({    
 		   required: true,    
 		   missingMessage:'输入用户名'   
 		});  
 		$('#password').validatebox({    
	 		required: true,    
	 		missingMessage:'输入密码'   
	 	});
 		
 		var r = $('#loginform').form('validate'); 
 		if (r) {
 			//document.loginform.action='system/login';
 			//document.loginform.submit();
 			$('#loginform').ajaxSubmit({
				url : contextPath + '/j_spring_security_check',
				success : function(result) {
					if (!result.success) {
						//$.messager.alert('提醒', data.message,'info');
						var html = '&nbsp; &nbsp;&nbsp; &nbsp;<font color="red">' + result.message +'</font>';
						$('#msg').html(html);
					} else {
						location.href = contextPath + result.data;
					}
				}
			});
 		} 
 	});
 	
 	$("body").keydown(function(){
 		//console.log(event);
 		if(event.keyCode == 13) {
 			// 回车触发登录按钮
 			$("#logining").click();
 		}
 	});
});


